package com.pqtest.api.service;

import com.pqtest.api.dto.SlSimulibrarySubmitDto;
import com.pqtest.api.dto.SlSimulibraryUpdatetimeDto;
import com.pqtest.api.entity.SlSimulibraryEntity;
import com.pqtest.api.mapper.SlSimuTestMapper;
import com.pqtest.api.utils.DtoEntityTransformer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SlSimuService {
    @Autowired
    SlSimuTestMapper slSimuTestMapper;
    public SlSimulibraryEntity getById(int id){
        return slSimuTestMapper.getById(id);
    }
    public List<SlSimulibraryEntity> getByUserId(int userId){
        return slSimuTestMapper.getByUserId(userId);
    }
    public int submit(SlSimulibrarySubmitDto slSimulibrarySubmitDto){
        SlSimulibraryEntity slSimulibraryEntity = new SlSimulibraryEntity();
        DtoEntityTransformer.transalte(slSimulibrarySubmitDto,slSimulibraryEntity);
        return slSimuTestMapper.submit(slSimulibraryEntity);
    }

    public int uptime(SlSimulibraryUpdatetimeDto slSimulibraryUpdatetimeDto){
        SlSimulibraryEntity slSimulibraryEntity = new SlSimulibraryEntity();
        DtoEntityTransformer.transalte(slSimulibraryUpdatetimeDto,slSimulibraryEntity);
        return slSimuTestMapper.uptime(slSimulibraryEntity);
    }
}